// import Home from '@/pages/Home/Home.vue'
import Login from '@/views/Login/index.vue'
import Register from '@/views/Register'
import Search from '@/pages/Search/Search.vue'
// import Detail from "@/views/Detail"
// import AddCartSuccess from "@/views/AddCartSuccess"
// import ShopCart from "@/views/ShopCart"
import Trade from "@/views/Trade"
import Pay from '@/views/Pay'
import PaySuccess from '@/views/PaySuccess'
import Center from '@/views/Center'

// 二级路由
import myOrder from '@/views/Center/myOrder'
import proupOrder from '@/views/Center/groupOrder'

export default [
    {
        // 重定向,在项目跑起来的时候就出现的路由
        path: '*',
        redirect: '/home'
    },
    {
        path: '/shopcart',
        name: 'shopcart',
        // 路由懒加载
        component: () => import("@/views/ShopCart"),
        meta: {
            show: true
        }
    },
    {
        path: '/addcartsuccess',
        name: 'addcartsuccess',
        // 路由懒加载
        component: () => import("@/views/AddCartSuccess"),
        meta: {
            show: true
        }
    },
    {
        path: '/detail/:skuid',
        component: () => import("@/views/Detail"),
        meta: {
            show: true
        }
    },
    {
        // 主页
        name: 'home',
        path: '/home',
        component: () => import("@/pages/Home/Home.vue"),
        meta: {
            // 判断是否显示Footer组件
            show: true
        }
    },
    {
        // 登录
        name: 'login',
        path: '/login',
        component: Login,
        meta: {
            show: false
        }
    },
    {
        // 注册
        name: 'register',
        path: '/register',
        component: Register,
        meta: {
            show: false
        }
    },
    {
        // 搜索
        name: 'search',
        path: '/search',
        component: Search,
        meta: {
            show: true
        }
    },
    {
        // 结算
        name: 'trade',
        path: '/trade',
        component: Trade,
        meta: {
            show: true
        },
        // 路由独享守卫
        beforeEnter: (to, from, next) => {
            if (from.path == "/shopcart") {
                next();
            } else {
                next(false);
            }
        }
    },
    {
        // 支付 
        name: 'pay',
        path: '/pay',
        component: Pay,
        meta: {
            show: true
        },
        // 路由独享守卫
        beforeEnter: (to, from, next) => {
            if (from.path == "/trade") {
                next();
            } else {
                next(false);
            }
        }
    },
    // 支付成功
    {
        name: 'paysuccess',
        path: '/paysuccess',
        component: PaySuccess,
        meta: {
            show: true
        }
    }
    ,
    {
        name: 'center',
        path: '/center',
        component: Center,
        meta: {
            show: true
        },
        children: [
            {
                path: '/myorder',
                name: 'myorder',
                component: myOrder
            },
            {
                path: '/prouporder',
                name: 'prouporder',
                component: proupOrder
            }
        ]

    }
]